<!--我的策略-->
<template>
  <div class="bg bg1" @viewappear="viewappear" @viewdisappear="viewdisappear">
    
    <!--菜单按钮-->
    <div class="height40"></div>
    <div class="row acenter">
      <SubMenuOval class="menu" :menus="menus" :menu="menu" @menuClick="menuClick"></SubMenuOval>
      <LImage class="history-image" :src="Config.img('strategy_history.png')" @click="historyClick"></LImage>
    </div>

    <SUp class="store" v-if="menu == 0" v-model="strategy"></SUp>
    <Run class="run" ref="Run" v-else></Run>
  </div>
</template>

<script>

//组件
import SubMenuOval from '@/public/view/SubMenuOval.vue'
import SUp from '@/up/SUp.vue'
import Run from '@/run/Run.vue'

//功能
import navigator from "@/_js/navigator"; 
import Config from "@/_js/config";
import broadcast from "@/_js/broadcast";

const globalEvent = weex.requireModule('globalEvent');
const weexFunction = weex.requireModule("WeexFunction");

import I18N from "@/_i18n/i18n";
var T = I18N.t;

export default {
  
  components: {
    SubMenuOval,
    SUp,
    Run,
  },

  data() {
    return {
      T:T,
      Config:Config,
      menus:[T('策略库'), T('执行中')],
      menu:0,
      strategy:undefined, //策略库
    };
  },

  mounted() {
    //启动成功通知
    broadcast.subscribe('StrategyHome', 'UpShow', (e)=>{
      this.menuClick(e.index);
    });
  },
  
  methods: {
    /*************************************************通信触发*/
    //完全显示
    viewappear() {
      weexFunction.logPageView('我的策略', true);
      this.$refs.store && this.$refs.store.viewappear();
      this.$refs.Run && this.$refs.Run.viewappear();
    },

    //完全隐藏
    viewdisappear() {
      weexFunction.logPageView('我的策略', false);
      this.$refs.Run && this.$refs.Run.viewdisappear();
    },

    /********************************** 点击触发*/
    //菜单点击
    menuClick(menu){
      if (Config.forceLogin()) {
        this.menu = menu;
      }
    },
    
    //历史点击
    historyClick(){
      if (Config.forceLogin()) {
        navigator.open('', 'run/HRun');
      }
    },
  }
}

</script>


<style src="@/_css/style.css"></style>
<style scoped>
.bg {
  width: 750px;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}
.store{
  margin-top: 40px;
  width: 750px;
}
.run{
  margin-top: 40px;
  width: 750px;
}
.history-image {
  position: absolute;
  width:40px;
  height:40px;
  right: 52px;
} 

/*********************** 公告*/
.notice{
  height:60px;
  padding-left: 60px;
  padding-right: 40px;
  margin-top: 2px;
}

/*********************** 菜单*/
.menu {
  margin-left: 20px;
}

/*********************** 宽高*/
.height40{
  height: 40px;
}
</style>